package net.lanelife.casino.caipiao.service;

import net.lanelife.casino.caipiao.entity.RegistrationCode;
import net.lanelife.casino.caipiao.repository.api.IRegistrationCodeRepository;
import net.lanelife.casino.caipiao.service.api.IRegistrationCodeService;
import net.lanelife.casino.common.repository.support.GenericRepository;
import net.lanelife.casino.common.service.support.GenericService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class RegistrationCodeService extends GenericService<RegistrationCode, Integer> implements IRegistrationCodeService {
	
	@Autowired
	private IRegistrationCodeRepository repository;
	
	public RegistrationCodeService() {
		super(RegistrationCode.class);
	}
	
	@Override
	protected GenericRepository<RegistrationCode, Integer> getRepository() {
		return repository;
	}
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void update(Integer id, Boolean available) throws Exception {
		RegistrationCode entity = repository.findOne(id);
		entity.setAvailable(available);
	}

}
